namespace ScrumSprintMonitor.Wpf.Application
{
	#region #using Directives

    using System;
    using System.Diagnostics.CodeAnalysis;

	using Extensibility;

	using Implementation;

	using Infrastructure;
	using Infrastructure.IoC;

	using Microsoft.Practices.Unity;

	using UI.Wpf;

	#endregion

	[SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses",
		Justification = "The UnityContainerAbstraction will create this class")]
	internal class UnityAppRuntimeModule : StandardModule
	{
		/// <summary>
        ///   Loads the module into the container.
		/// </summary>
		public override void Load()
		{
			Container.RegisterInstance<IUnityContainer>(Container);
            Container.RegisterType(typeof(ILogger<>), typeof(Log4netLogger<>));
            Container.RegisterType(typeof(IAddInHost<>), typeof(AddInHost<>));

			SetupRuntimeBindings();
		}

		private void SetupRuntimeBindings()
		{
            Container.RegisterType<IResourceManager, ResourceManager>(new ContainerControlledLifetimeManager());
            Container.RegisterInstance<IConfigurationManager>(Settings.Default);

            Container.RegisterType<IProcessTemplateAdapterProvider, MefProcessTemplateAdapterProvider>(new ContainerControlledLifetimeManager());
            Container.RegisterType<IConnectionProvider, ConnectionProvider>(new ContainerControlledLifetimeManager());
            Container.RegisterType<IAvatarProviderStore, AvatarProviderStore>(new ContainerControlledLifetimeManager());
		}
	}
}